﻿using System;
using Cinemachine;
using Entitas.Unity;
using Script.Manager;
using UnityEngine;

public class PlayerView : View, IPhysics
{
    [SerializeField] private Transform                _shoot;
    [SerializeField] private Rigidbody2D              _rb2;
    private                  CinemachineVirtualCamera playerCam;

    public Transform   shoot => _shoot;
    public Rigidbody2D rb2   => _rb2;

    protected override void OnLinkEntityHandler ()
    {
        base.OnLinkEntityHandler ();
        playerCam        = FindObjectOfType<CinemachineVirtualCamera> ();
        playerCam.Follow = transform;
    }

    protected override void OnDestoryEntityHandler ()
    {
        base.OnDestoryEntityHandler ();
        playerCam.Follow = null;

        PoolManager.Instance.Recycle (this, ActorTag.Player);
    }
}